package com.domain;

import java.util.List;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;

public class PagingEntity {
	
	//第几页
	private int page = 1;
	
	//每页记录数
	private int pageSize = 10;
	
	//查询起始索引                 
//	private int beginIndex = 0;
	
	// 是否查询总数 默认是true，首先查询总数。
	private boolean isCount = true; 

	// 总记录数
	private int total;
	
//	private Integer totalPage;//总页数,可通过Math.ceil((double)total/pageSize)计算
	
	// 返回页面的数据
	private List<? extends PagingEntity> rows; 

/*	private void countEndAndIndex(){
		//计算oracle 分页所用到的 开始和结束  rownum
		this.endIndex = (this.page * this.pageSize +1);
		this.beginIndex = (this.page-1) * this.pageSize + 1;
		//计算mysql
		this.beginIndex = (this.page-1) * this.pageSize;
	}*/
	
/*	public int getBeginIndex() {
		return beginIndex;
	}

	public void setBeginIndex(int beginIndex) {
		this.beginIndex = beginIndex;
	}*/

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
//		countEndAndIndex();
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
//		countEndAndIndex();
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public boolean getIsCount() {
		return isCount;
	}

	public void setIsCount(boolean isCount) {
		this.isCount = isCount;
	}

	public List<? extends PagingEntity> getRows() {
		return rows;
	}

	public void setRows(List<? extends PagingEntity> rows) {
		this.rows = rows;
	}
	
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
	
}
